#ifndef KEYBOARDCONTROLLER_H
#define KEYBOARDCONTROLLER_H

#include <QObject>

#include "Controller.h"
#include "Mob.h"
#include "GameWidget.h"

  // used to controll player by using keyboard ( mouse support incoming later )
class KeyboardController : public QObject, public Controller
{
    Q_OBJECT
    public slots:
        bool event( QKeyEvent* e ) { return action( e ); }
    public:
        static const char KEYBOARDCONTROLLERCHAR = 'K';

        KeyboardController( Mob* mob_ = 0, GameWidget* w = 0)
            :Controller( mob_ ), widget( w )
        {
            connect( widget, SIGNAL( keyPress(QKeyEvent*) ), SLOT( event(QKeyEvent*) ) );
            lastUpdate = -1;
        }

        GameWidget* getWidget() const { return widget; }
        void setWidget( GameWidget* i ){ widget = i; }

        char getType() const{ return KEYBOARDCONTROLLERCHAR; }
        bool action( QKeyEvent* event = 0 );
    protected:
    private:
        GameWidget* widget;
          // used to prevent multymoving on the same update
        int lastUpdate;
};

#endif // KEYBOARDCONTROLLER_H
